package cn.ytnet.shangyun.service.basic.dao.impl;

import cn.ytnet.shangyun.service.basic.dao.ProvinceDAO;
import cn.ytnet.shangyun.service.basic.entity.ProvinceEntity;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by cyongk on 2015/12/8.
 */
@Repository("provinceDAOImpl")
public class ProvinceDAOImpl implements ProvinceDAO {

    @Resource
    private SessionFactory sessionFactory;

    public void saveProvince(ProvinceEntity provinceEntity) {
        Session session = sessionFactory.getCurrentSession();
        session.save(provinceEntity);
    }

    public List<ProvinceEntity> findAllProvince() {
        Session session = sessionFactory.getCurrentSession();
        Query query = session.createQuery("from ProvinceEntity");
        List<ProvinceEntity> list = query.list();
        return list;
    }

    public void updateProvince(String id, ProvinceEntity provinceEntity) {
        //this.getHibernateTemplate().update(id,provinceEntity);
    }
}
